Method for efficient routing in a network interface card

ABSTRACT

Packet switching is facilitated between a source and a destination through a network interface card. In accordance with an aspect, a NIC is configured to switch ingress packets—coming from the network—selectively to one or multiple destinations (in a NIC which is capable of replicating packets) on the host computer, and alternatively or additionally (in a NIC which is capable of replicating packets) back to one or multiple destinations on the network. In multi-port NICs, this capability effectively allows a NIC to perform the basic functions of a standalone network switch as well as additional useful functions.

TECHNICAL FIELD

The present invention relates to packet switching and processing in apacket network interface card.

BACKGROUND

A Network Interface Controller (NIC)—which may be, for example, networkinterface circuitry, such as on a PCI card connected to a host computervia a PCI host bus—is typically used to couple the host computer to apacket network through at least one NIC interface, called a port.Recently, the growth in host virtualization has led to additionalfunctionality being performed by virtualization-aware NICs. One class ofsuch functionality is packet switching, which allows multiple virtualoperating systems or guest operating systems on a host system tocommunicate with each other through a NIC attached to the computersystem. A related standardization effort of virtual machine switching isunder way.

SUMMARY

Packet switching is facilitated between a source and a destinationthrough a network interface card. In accordance with an aspect of theinvention, a NIC is configured to switch ingress packets—coming from thenetwork—selectively to one or multiple destinations (in a NIC which iscapable of replicating packets) on the host computer, and alternativelyor additionally (in a NIC which is capable of replicating packets) backto one or multiple destinations on the network. In multi-port NICs, thiscapability effectively allows a NIC to perform the basic functions of astandalone network switch as well as additional useful functions.

BRIEF DESCRIPTION OF FIGURES

FIG. 1 is a block diagram illustrating a host system with a networkadapter configured to, based on a least a portion of a packet receivedon one of a plurality of ports, indicate a destination of the packet ora replica thereof that is at least one of any one of the ports and/orany of receive queues for providing the packet to the host.

FIG. 2 is a flowchart illustrating an example of the process that may befollowed in the FIG. 1 network adapter.

FIG. 3 illustrates compressed n-tuple formats usable for n-tupleclassification.

DETAILED DESCRIPTION

The inventors have realized a novel application of the switchingcapability of a NIC—namely the switching of ingress packets—coming fromthe network—selectively to one or multiple destinations (in a NIC whichis capable of replicating packets) on the host computer, andalternatively or additionally (in a NIC which is capable of replicatingpackets) back to one or multiple destination on the network. Inmulti-port NICs, this capability effectively allows a NIC to perform thebasic functions of a standalone network switch as well as additionaluseful functions. Within this patent application, the terms “frame” and“packet” are used interchangeably. While convention is to refer toEthernet “frames,” but to IP “datagrams” and TCP “segments” and ingeneral to network” packets,” these two terms—i.e. frames andpackets—are used somewhat interchangeably because the data representedby these terms is, in many places, treated somewhat interchangeably. Forany particular example, the characteristic of the actual data beingprocessed/handled is evident from the context.

Furthermore, a rich set of operations may be performed on a packet,including replicating packets, before a packet is sent towards itsdestination. Such operations include full or partial header removal,full or partial header rewrite (e.g., to implement routerfunctionality), header insertion, full or partial payload removal,payload insertion or other payload processing, partial or full protocolprocessing and packet segmentation. The particular processing appliedmay depend on the results of a look up using some information present inthe packet or a look up using information computed in part or in fullbased on information present in the packet, and may additionally oralternately depend on other information internal to the NIC.

In some examples, such an operation performed on a packet includesreplicating of partial packet contents, such as for high speed tracingof critical packet information in headers.

In some examples, different processing may be performed on differentcopies of the replicated packets originating from a single receivedpacket. For example, one replicated packet may be provided to the host,one provided to an output port for transmission to a remote monitor, andone passed through the NIC (routed). In some examples, an operationperformed on a replicated packet includes associating with a replicatedpacket, a virtual identifier (VI) derived from the received packet, forexample derived from the destination Ethernet address in the receivedpacket, and then providing the replicated packets to the ingresspipeline of the NIC with a tuple including the VI. A filter rule can bewritten for each VI and each filter can specify a particular action. Thediscussion henceforth will consider an Ethernet network as an example ofa packet switched network where this use of a NIC switching capabilitymay be applied, though other types of packet-switched networks/protocolsmay be employed as well.

The NIC can do multi-layer (referring to the OSI layered network model)processing, such as L2-L7 processing, on a packet (for both ingress andegress directions). In particular, the NIC may parse the various headersand can be programmed via the host system with various packetcharacteristic criteria—to modify the packet contents, or drop thepacket or send the packet for further processing in the host,transparently (e.g, by replication) or not (e.g., by extracting thepacket from the ingress stream). In some cases, ingress packets arepackets that were egress packets but, upon egress, it was determinedthat the destination address (e.g., at Layer 2) is such that the egresspacket is destined to the same NIC, is for example being sent from onevirtual machine to another virtual machine on the host connected to theNIC, in which case the egress packet is then looped back to the NIC foringress processing (including Layer 2 processing) as if the packet hadbeen received at an input port of the NIC. In this case, the NICperforms processing like that of an L2 Ethernet switch. The egress toingress switching determination step may also consider fields at layersabove L2. In this case, the NIC performs processing that goes beyondthat of an L2 Ethernet switch. Furthermore, an ingress packet which wasan egress packet can be sent on an egress port following the ingressprocessing step. Multiple such iterations through the NIC may occur, andcan be useful to perform cascaded operations on the packets.

Thus, for example, the NIC may accomplish, in a unified manner,functions such as routing, switching and firewall functions, in additionto other functions that may typically be handled by a NIC—such as TCP orother layer 2/3 protocol offload, layer 2 protocol endpoint processing,etc.

FIG. 1 is a block diagram illustrating an example host system 102including a host 112 with a network adapter (NIC 108) configured to,based on at least a portion of a packet received on one of a pluralityof ports, indicate a destination of the packet that is at least one ofany one of the ports and/or any of receive queues for providing thepacket (or data resulting from protocol processing the packet) to thehost, or a “null” interface to drop the packet. The FIG. 1 NIC includescapability to perform initial MAC address level filtering 110 on aninput packet received (such as from a peer 104 via a network 106),depending on a setting of a configurable promiscuous mode of the NIC108. Thereafter, a filter mechanism 111 includes capability to pass,drop or proxy a packet depending on a classification of the packet asdetermined using an n-tuple of the information in the packet. Theproxied packets are sent to network 107, which could be different fromnetwork 106. Following, we discuss this network adapter capability inmore detail, with reference to examples.

Classification and Filtering refer to a sequence of processing stepsinvolving the determination of information based at least in part on thepacket, and based on a result of a lookup using this information inpre-programmed classification tables to perform further processing ofthe packet.

In accordance with an example embodiment, a packet input on a port ofthe network interface controller is processed and, based thereon, eitherswitched to be output or provided to a receive queue of the host (to bethereby provided to the host), or protocol processed by the NIC and aresult of the protocol processing provided to the host and/or proxied toa peer. Furthermore, as a preliminary step, it may be determined if thenetwork interface controller is to even accept a frame that includes theinput packet to be processed. For example, it may be determined if theMAC address in the frame matches a MAC address in an accept list. If theMAC address matches, then the frame is accepted. Otherwise, if the MACaddress does not match, it is dropped, unless the NIC is in apromiscuous mode.

Next, a filter lookup is performed based on characteristics of theingress packet. The filter lookup is an n-tuple classification feature,which can be used in the ingress path to, for example:

-   -   Steer ingress packets that meet ACL (Access Control List) accept        criteria to a particular receive queue on the host.    -   Protocol process ingress packets that meet ACL accept criteria,        and deliver a result of the processing to a particular receive        queue on the host.    -   Switch (proxy) ingress packets that meet ACL accept criteria to        an output port, with optional header rewrite and network address        translation NAT (IPv4/IPv6 addresses and TCP/UDP ports).    -   Drop ingress packets that fail ACL accept criteria.

The filter may be implemented by configuring space forclassification/filter rules within the LE (“lookup engine”) lookup table(an example implementation of which is a TCAM), and initializing thefilter rule state at the index value corresponding to the rule withclassification/filter rule specific information.

The classification n-tuples may be priority encoded such that, whenthere are multiple hits in the LE classification/filter region, then theindex for the matching rule with the lowest index value within theclassification/filter region is returned. The ACL processing of ingresspackets can be enabled separately (e.g., in a configuration register).There can be multiple DROP rules within the LE and matching such a ruleindicates that a packet should be dropped, whereas the PASS and PROXYrules are stored only within a control block that is accessed using thematching rule index. This arrangement allows ACL processing inconjunction with offloaded connections, i.e. an incoming TCP SYN(connect request) can be classified for PASS/DROP and then when PASS isindicated, the LE can look up an offloaded listening server. (See U.S.Pat. No. 7,760,733 for a description of an example LE operationincluding the lookup of an offloaded listening server.)

The n-tuple classification feature uses, for example, 512 MAC Ethernetexact match address filters and 256 hashed Ethernet address (partial)match filters in the MPS (Multi Purpose Switch), and the TP (TransportProcessor) parser then extracts information from each ingress Ethernetpacket and passes it to the classification engine that looks up then-tuple in the filter region within the LE TCAM.

We now describe an example ingress path processing in greater detail,with reference to FIG. 2. As shown in FIG. 2, in the incoming frame, theframe destination MAC address is looked up in a MAC address matchingtable. The incoming frame is parsed, and the MAC address match describedabove is performed, for example, at the speed of the incoming frame,such as 10 Gbps network speed.

The parser may extract the following, for example, from the incomingframe: EtherType, ingress Port number, Outer VLAN, Inner VLAN, Protocol,Local IP Address (LIP), Local port number (LP), Foreign/Peer IP address,Foreign/Peer Port number (FP). The parser may also derive additionalfields based in part on the extracted fields, such as derive a PCIVirtual Function number VF and PCI Physical Function number PF. Thechoice between some fields, for example Outer VLAN or VF, PF may beselected, by a control process, through a configuration register of theNIC that is accessible to the control process.

It may be beneficial (economical) to produce a compressed tuple stringby selecting and concatenating the information above using the settingof a register. Different possible values of this register may be set toselect the different fields in the filter tuple. The compressed tuplestring may be looked up in a rule database; any of the tuples can have awildcard value. In one example, there are 256 rules in a standardconfiguration (with up to 2048 rules possible). The lookup is done atthe ingress (e.g., 10 Gbps) line rate, and the result is a value for“index tid.”

The matching rule is obtained (at index tid), and the rule specifies anaction: DROP/PASS/OFFLOAD/PROXY. If the rule specifies PASS (Deliver),the Queue Number for the received packet is fetched for the rule. If therule specifies OFFLOAD, the ingress packet is protocol processedaccording to a network protocol such as TCP/IP and a result of theprocessing may be delivered to a Queue Number specified in the rule. Ifthe rule specifies PROXY, an egress packet is re-injected into theegress processing path after optionally re-writing the MAC header, VLAN,and/or TCP/UDP port fields. It is possible to construct rich processingrules with combinations of the actions listed here, such as OFFLOADprotocol processing followed by PROXY of a result of the protocolprocessing.

The packet is delivered to an appropriate Receive Queue. In one example,there is support for 1024 Receive Queues.

There is a tradeoff between the size of the n-tuple, the number of bitsin the n-tuple, and the number of filters that can be supported. In oneexample it is possible to support 2048 132-bit n-tuples or 512 528-bitn-tuples. The 528-bit n-tuple is large enough to contain all the headerfields extracted by the parser and is also large enough to contain partsof the packet payload. The 132-bit n-tuple is only large enough tocontain a subset of the information extracted by the parser, and the132-bit n-tuple which is referred to as a compressed n-tuple for thisreason, employs a selection mechanism to select which fields are used inthe n-tuple. The advantage of the larger tuples is the flexibility inspecifying matching conditions and the advantage of the compressedn-tuple is that a greater number of filters that can be supported.

A compressed n-tuple format used for n-tuple classification, for IPv4and IPv6 may be as shown in FIG. 3. The parser extracts the type of apacket, e.g., IPv6, IPv4 or non-IP. The IPv6 packets use a 288+36=324bit wide tuple, and all other packets use a 96+36=132 bit tuple, where288 is the width in bits of the IPv6 4-tuple, 96 is the width in bits ofthe IPv4 4-tuple, and 36 is the width in bits of the filter tuple.

In one example, the filter tuple may be configured using a 9-bit maskand 1-bit compaction selector (e.g. using a programmable register), withthe different fields of the tuple being as shown in the following table,and the value in the register that selects that field, i.e., when a bitis set in a column, the field in the column is part of the filter tuple.There are 84 possible non-compacted combinations of the tuple that fitwithin the 36 bits, and these are the legal configurations of thecompacted filter tuple. The size of the filter tuple in the exampleembodiment is 36 bits. There are an additional 24 compacted compressedfilter formats which may be selected with a mode bit in theconfiguration register.

Further efficiency can be achieved by constructing compacted forms ofsome of the fields in the n-tuple. For example a compacted IP Protocolfield format uses a compacted representation of the IP protocol field torepresent the most popular protocols or protocols of interest (e.g.ICMP, TCP and UDP), and this field includes an encoding for FCoE (FibreChannel over Ethernet) and IP fragments. See Compacted PROTOCOL entry intable below.

TABLE 1 Compressed Classification Tuple Format Programmable Registerbits [9:0] Programmable Register bit [15] == 0, compact mode selectornot enabled IP MATCH MATCH VNIC Fragment TYPE ID EtherType Protocol TOSiVLAN ID PORT FCoE (1-bit) (3-bits) (1-bit) (16-bits) (8-bits) (8-bits)(17-bits) (17-bits) (3-bits) (1-bit) 1 1 1 1 0 0 0 0 1 1 1 1 1 0 1 1 0 01 1 1 1 1 0 0 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 0 1 1 1 0 0 0 0 1 1 0 11 0 0 0 1 1 1 1 0 1 0 1 0 0 1 1 1 1 0 0 1 0 1 0 1 1 1 1 0 0 1 0 0 1 1 11 1 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0 10 0 0 1 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 0 1 1 01 0 0 1 0 1 0 1 1 0 0 1 1 1 0 0 1 0 1 0 0 1 1 1 0 0 0 1 1 0 0 1 0 0 1 00 1 1 0 0 1 0 0 0 1 0 1 1 0 0 0 1 1 1 0 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 00 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 0 1 1 1 0 0 0 10 1 0 1 0 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 1 0 0 1 10 1 0 0 0 0 1 1 1 0 0 0 1 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 0 0 1 1 0 00 1 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 1 0 11 0

TABLE 2 Compacted Compressed Classification Tuple Format ProgrammableRegister bits [9:0] Programmable Register bit [15] == 1, compact modeselector enabled IP MATCH Compact VNIC Fragment TYPE MATCH EtherTypeProtocol TOS iVLAN ID PORT FCoE (1-bit) (3-bits) (1-bit) (16-bits)(2-bits) (8-bits) (17-bits) (17-bits) (3-bits) (1-bit) 0 1 1 1 1 1 0 0 00 0 1 1 1 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 0 1 1 1 0 1 0 0 1 0 0 1 1 1 00 0 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 0 1 1 0 1 1 0 0 1 1 0 1 0 1 1 0 0 01 1 0 1 0 1 0 1 0 0 1 1 0 0 1 1 0 1 0 0 1 1 0 0 0 1 1 1 0 0 1 0 1 1 1 01 1 0 0 1 0 1 1 0 1 0 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 0 1 1 1 1 0 0 0 1 00 1 1 1 0 1 0 0 1 0 0 1 0 1 1 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 1 1 1 0 0 10 0 0 1 1 1 0 0 1 1 0 0 0 1 0 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 0 0 0 0 1 10 1 0 1 0 0 0 0 0 1 1 1 1 1 0

Table 4, below, describes the fields in an example filter format.

TABLE 3 Filter Tuple Format Width Field bits Description IP fragment 1Ingress IPv4 or IPv6 packet is fragmented MAC_ 3 Multipurpose switch(MPS) match MATCH_TYPE type, see table below MAC_IDX 9 MPS match indexETH_TYPE 16 Ethernet type PROTOCOL 8 8b protocol field within IP headerCompact 2 0 - not used PROTOCOL 1 - FCoE 2 - UDP (not fragmented) 3 -TCP (not fragmented) TOS/Traffic Class 8 8b IPv4 Type Of Server/IPv6Traffic Class IVLAN_VLD 1 Inner VLAN tag is valid IVLAN 16 16b InnerVLAN tag VNIC_ID_VLD 1 Depending on bit setting in TP_INPUT_ VNIC_ID 16CONFIG selects between an ID derived from VF_VLD, PF, VF or outer VLAN:1 VF_VLD 3 PF 6 unused 7 VF 1 OVLAN_VLD 16 OVLAN PORT 3 Port wherepacket arrive with a value of 0-3 denoting Ethernet ingress ports 0-3,and a value of 4-7 denoting loopback packets from a particular egresschannel (channel 0 corresponding to 4, channel 1 to 5, 2 to 6, and 3 to7)

Table 5 shows an example of possible values for the match type field,which is generated by the L2 lookup step.

TABLE 4 MAC_MATCH_TYPE Value Name Comments 0 UCAST_ The MAC address ofthe Ethernet frame is a unicast CAM address and it hit in the MPS MACaddress TCAM (Ternary Context Addressable Memory) and the MacIndex valuewill indicate the index of the CAM entry that was hit. 1 UCAST_ The MACaddress is a unicast address and it hit in the HASH MPS MAC address hashon an entry marked valid. The MacIndex value will indicate the index ofthe entry in the per interface hash table, and the Interface field willindicate which per Interface hash table. 2 MCAST_ The MAC address of theframe is a multicast address CAM and it hit in the MPS MAC address CAM.See UCAST_CAM comments for further explanation. 3 MCAST_ The MAC addressof the frame is a multicast address HASH and it hit in the MPS MACaddress hash on an entry marked valid. See UCAST_HASH comments forfurther explanation. 4 PROM The frame is received as a promiscuousframe. There is a promiscuous enable bit per interface in MPS, and thereis a configuration bit for the precedence of the promiscuous modeclassification decision. In this case the promiscuous frameclassification decision is configured to have the lowest precedence,i.e. after all the above and BCAST. The frame is received because theinterface where it arrived has promiscuous mode enabled, and the framematched none of the other criteria. 5 HYPER_ The frame is received as apromiscuous frame (see PROM PROM above for contrast). In this case theprecedence of the promiscuous mode classification is configured in MPSto have higher precedence than the CAM and HASH, but lower than BCAST.The frame is received because the interface where it arrived haspromiscuous mode enabled, and the frame is not a broadcast frame. 6BCAST The MAC address is a broadcast address. 7 NO- This value is onlyreturned in MPS debug mode and MATCH indicates that the frame matched nocriteria.

We now discuss examples of various ingress packets. For example, for theTCP connect request ingress packets, the server/control-plane willtypically be asked to validate the connection request and to deny,reject, or accept the connect request. For offloaded connections (i.e.,the TCP protocol processing is offloaded from a host protocol processingstack to the NIC), the TCP engine will look up the TCB (TCP ControlBlock) connection state, to access the queue number within the TCBstate, to select the appropriate queue pair to use for TCP connectionsand iSCSI connections. For iWARP RDMA connections, the queue pairinformation is stored as part of the TCB state. Finally, for filterrules, the TCB state that is accessed using the index of the filter rulespecifies if a packet that matches the rule should be dropped (DROPrule), should be passed (PASS rule) to the host, should be protocolprocessed (OFFLOAD rule) or should be proxied (PROXY rule) to aparticular output port. In the PASS rule case the queue number that isstored as part of the TCB can be used to specify a receive queue towhich the particular packet is steered. Alternatively, packets hitting aPASS rule can be distributed to multiple queues through RSS (ReceiveSide Scaling) mechanisms.

Creating Filter Rules

In one example, the filter rules are setup via a control plane messagereferred to as the SET_LE_REQ message with the type of command being awrite command that initializes a filter entry within the filter regionof the Lookup Engine (LE) TCAM; and with a control plane messagereferred to as a SET_TCB or SET_TCB_FIELD message that initializes theclassification rule TCB.

In an example, the filter region within the LE may be set by programmingthe LE_DB_FILTER_TABLE_INDEX register, ensuring that the filter index isgreater than the server index and less than the CLIP index. Note thatthe index of each region, in one example, must be a multiple of 128. TheFilter region is then enabled by setting the corresponding bit in theLE_DB_CONFIG register.

The SET_LE_REQ message may be used to write the n-tuple information intothe filter entry, using the LE_DB_WRITE command. Each filter canindependently be configured to take precedence over hits in the Activeand Server regions of the LE. This can be accomplished through accessingthe priority filter configuration register.

Filter Rule

A filter rule may be implemented with a TCAM entry and a TCB entrycorresponding to the tid of the filter rule.

Example TCB fields used for filter rules are shown in Table 6, and therest of the TCB is set to zeros:

TABLE 5 Filter TCB RSS Flags Description Comments Filter This bit mustbe set for all filter rules. Report TID When set, the RSS hash fieldwill report the filter TID instead of the hash value. Drop When set,packets which match the filter rule are dropped. Direct Steer When set,packets which match the filter rule are direct steered, and follow theoffloaded event configuration. Otherwise, a hash is computed and used inlooking up the receive queue number, per tunnel packet configuration.Mask Hash When set, the computed hash is masked using the MaskValuespecified in TP_RSS_CONFIG_TNL and OR'ed into the RSS field in the TCB,right extended by 1 bit of zero. Only applicable when Direct Steer isclear. Direct Steer When set, the RSS field in the TCB is interpreted asa Hash hash value, left extended by 1 bit of zero, regardless of theoffload event settings. Otherwise, it is interpreted according to theoffload event settings, e.g. as a final queue number. Only applicablewhen Direct Steer is set. Count Hits When set, filter hits and hit bytesare accounted in the TCB. Loopback Loop packets which hit this filterback to transmit. The loopback transmit channel number is specifiedbelow. Additional NAT support is configured per table below, Loopback TXTransmit channel and interface (port) number for Channel loopbackpackets. Swap MAC Swap SMAC and DMAC addresses for loopback addressespacket, before any rewrite operations. Rewrite DMAC Replace the incomingDMAC with the one pointed to by the TCB's l2t_index field, if the DMACaddress value is non-zero. This applies to loopback frames only. RewriteSMAC Replace the incoming SMAC with the one painted to by the TCB'ssma_sel field, if the SMAC address value is non-zero, This applies toloopback frames only, Insert VLAN If the VLAN tag in the L2T entrypointed to by the TCB's l2t_index field is not l2′hFFF, then the VLANtag is inserted in the looped back packet. Note that VLAN rewritecorresponds to both InsertVLAN and RemoveVLAN being set. This applies toloopback frames only. Remove VLAN If he incoming packet has a VLAN tagthen the VLAN tag is removed before the packet is looped back. Note thatVLAN rewrite corresponds to both InsertVLAN and RemoveVLA1N being set.This applies to loopback frames only.

Table 7 shows examples of Filter Loopback NAT flags.

TABLE 6 Filter Loopback NAT Flags NAT Mode Specifies NAT mode forloopback filters: Value Setting 3′b000 No NAT preformed 3′b001 Only DIPrewritten 3′b010 DIP/DP rewritten 3′b011 DIP/DP/SIP rewritten 3′b100DIP/DP/SP rewritten 3′b101 SIP/SP rewritten 3′b110 DIP/SIP/SP rewritten3′b111 All 4-tuple fields rewritten NAT sequence When set, filter-basedloopback with NAT enabled is check only applied to segments satisfyingthe check: SEQ_LT(seq_no + pld_len, rcv_nxt) NAT flag check When set,filter-based loopback with NAT enabled is only applied to segments whichdo not have the TCP FIN flag or RST flag set.

In one example, the addresses used in the NAT functionality are storedin the most significant 288 bits of the TCB as follows:

-   -   tcb[1023:1008]=SP    -   tcb[1007:992]=DP    -   tcb[991:960]=SIP4    -   tcb[959:928]=DIP4    -   tcb[991:864]=SIP6    -   tcb[447:320]=DIP6        Additionally, if the “NAT sequence check” flag is set, then only        ingress TCP segments satisfying the        SEQ_LT(seq_no+pld_len,rcv_nxt) check (relative to the rcv_nxt        value in the TCB) are looped back. All other sequence numbers        are sent to the host, steered as normal tunnel packets. A        “tunnel packet” is a packet that is provided for protocol        processing to a software protocol stack operating on the host.        Furthermore, if the “NAT flag check” flag is set, then only        ingress TCP segments with the TCP FIN and RST flags not set are        looped back.        Filter Hit Count

A 64 bit hit count per filter is configurably maintained. The count isincremented for packets which do not fail the basic sanity checking(checksums etc. . . . ), and can be read by using a GET_TCB or aSET_TCB_FIELD with zero mask and data to access the count location inthe TCB. It can also be written if need be using SET_TCB_FIELD.

A 64 bit hit byte count per filter is configurably maintained. The countis incremented for packets which do not fail the basic sanity checking(checksum etc. . . . ), by the length of the packet in bytes, and can beread by using a GET_TCB or a SET_TCB_FIELD with zero mask and data toaccess the count location in the TCB. It can also be written if need beusing SET_TCB_FIELD.

We have thus described a system and method by which ingresspackets—coming from the network—may be switched selectively to one ormultiple destinations, and alternatively or additionally (in a NIC whichis capable of replicating packets) back to one or multiple destinationson the network. In multi-port NICs, this capability effectively allows aNIC to perform the basic functions of a standalone network switch aswell as additional useful functions.

What is claimed is:
 1. Network interface circuitry configured to couplea host computer and a network, comprising: a plurality of portsconfigured to transmit packets to and receive packets from the network;a memory configured to implement a plurality of receive queues forfacilitating receipt of data by the host, the data being at least aportion of the packets received; logic to, based on a least a portion ofa packet received on one of the plurality of ports, indicate whichdestination of one of any one of the ports and the host to indicate as adestination of data of the packet, wherein indicating the destination assaid one of said any of the ports is an indication that the data of thepacket is to be transmitted back out to the network from the networkinterface circuitry via the indicated said port.
 2. The networkinterface circuitry of claim 1, wherein: the network interface circuitryis configured to offload protocol processing from a host stack; and thelogic includes logic to determine whether the network interfacecircuitry is to perform offload protocol processing with regard to thereceived packet.
 3. The network interface circuitry of claim 1, wherein:the indication of the host as the destination of the packet includes anindication of one of a plurality of receive queues by which the hostreceives the data of the packets.
 4. The network interface circuitry ofclaim 1, wherein: the logic is further configured to cause rewrite of aheader of the packet, whereby the network interface circuitry operatesas a router for packets for which a header has been rewritten.
 5. Thenetwork interface circuitry of claim 1, wherein: the logic is configuredto rewrite at least one of both a layer two and layer three header, andonly a layer three header, to thereby accomplish routing of the receivedpacket.
 6. The network interface circuitry of claim 1, wherein: when thedestination is any one of the ports and the logic indicates that thenetwork interface circuitry is to operate as a proxy for the data of thepacket, the network interface circuitry is configured to interoperateover the network, with the network interface circuitry as an origin anda peer destination of a packet including the data, reachable via thedestination port and over the network.
 7. The network interfacecircuitry of claim 1, wherein the logic is further configured toselectively cause, based on indicating a destination of data of apacket, replication and multicast of the data of the packet.
 8. Thenetwork interface circuitry of claim 1, wherein the logic is furtherconfigured to cause rewrite of a payload portion of the data of thepacket.
 9. The network interface circuitry of claim 1, wherein the logicis further configured to cause insertion of a tag in a header portion ofthe packet.
 10. The network interface circuitry of claim 1, wherein thedestination indication logic is responsive at least in part to aconfiguration area of the network interface circuitry that isconfigurable with values by software executing on the host computer. 11.The network interface circuitry of claim 6, wherein: the networkinterface circuitry is configured to offload protocol processing from ahost stack to terminate a connection between the host and a first peerwith respect to the received packet; and the logic includes logic todetermine whether the network interface circuitry is to perform offloadprotocol processing with regard to the received packet and, further,whether the network interface circuitry is to operate as a proxy for thedata of the protocol-processed packet, the network interface circuitryis configured to interoperate over the network, with the networkinterface circuitry as an origin and a peer destination of a packetincluding the data, reachable via the destination port and over thenetwork.
 12. The network interface circuitry of claim 6, wherein: thenetwork interface circuitry is further configured to provide a copy ofat least a portion of the received packet to the host.
 13. The networkinterface circuitry of claim 1, wherein: the logic includes logic toreplicate at least a portion of the data of the received packetresulting in at least one replicated packet, and the logic furtherincludes logic to process the at least one replicated packet based atleast in part on the data included in the at least one replicatedpacket.
 14. The network interface circuitry of claim 13, wherein: thelogic includes logic to replicate at least a portion of the receivedpacket resulting in at least one replicated packet includes logic toassociate a virtual address as a layer 2 address for the at least onereplicated packet, and the logic further includes logic to process theat least one replicated packet based at least in part on the associatedvirtual address.
 15. The network interface circuitry of claim 1,wherein: the destination indication logic includes logic to process atleast a portion of the packet and to selectively prevent, based thereon,the packet from being transmitted to the network from the networkinterface circuitry.
 16. A method of coupling a host computer and anetwork, comprising: via a plurality of ports of network interfacecircuitry that couples the host computer and the network, transmittingpackets to and receiving packets from the network; configuring a memoryto implement a plurality of receive queues for facilitating receipt ofdata by the host, the data being at least a portion of the packetsreceived; and operating logic to, based on a least a portion of a packetreceived on one of the plurality of ports, indicate which destination ofone of any one of the ports and the host to indicate as a destination ofdata of the packet, wherein indicating the destination as said one ofsaid any of the ports is an indication that the data of the packet is tobe transmitted back out to the network from the network interfacecircuitry via the indicated said port.
 17. The method of claim 16,wherein: the network interface circuitry is configured to offloadprotocol processing from a host stack; and operating the logic includesoperating the logic to determine whether the network interface circuitryis to perform offload protocol processing with regard to the receivedpacket.
 18. The method of claim 16, wherein: operating the logic furtherincludes operating the logic to cause rewrite of a header of the packetwhereby the network interface circuitry operates as a router for packetsfor which a header has been rewritten.
 19. The method of claim 16,wherein: operating the logic further includes operating the logic torewrite at least one of both a layer two and layer three header, andonly a layer three header, to thereby accomplish routing of the receivedpacket.
 20. The method of claim 16, wherein operating the logic furtherincludes operating the logic to selectively cause, based on indicating adestination of data of a packet, replication and multicast of the dataof the packet.
 21. The method of claim 16, wherein operating the logicfurther includes operating the logic to cause rewrite of a payloadportion of the data of the packet.
 22. The method of claim 16, wherein:operating the logic further includes operating the logic to replicate atleast a portion of the data of the received packet resulting in at leastone replicated packet, and operating the logic to process the at leastone replicated packet based at least in part on the data included in theat least one replicated packet.
 23. The method of claim 22, wherein:operating the logic further includes operating the logic to replicate atleast a portion of the received packet resulting in at least onereplicated packet includes logic to associate a virtual address as alayer 2 address for the at least one replicated packet, and operatingthe logic to process the at least one replicated packet based at leastin part on the associated virtual address.
 24. The method of claim 16,wherein: operating the logic includes operating the logic to process atleast a portion of the packet and to selectively prevent, based thereon,the packet from being transmitted to the network from the networkinterface circuitry.
 25. Network interface circuitry configured tocouple a host computer and a network, comprising: a plurality of portsconfigured to transmit packets to and receive packets from the network;a memory configured to implement a plurality of receive queues forfacilitating receipt of data by the host, the data being at least aportion of the packets received; logic to, based on a least a portion ofa packet received on one of the plurality of ports, indicate whichdestination of one of any one of the ports and the host to indicate as adestination of data of the packet.